
/**
 * @author Lukas Koell
 * @author David Medenjak
 * @author Johannes Riedmann
 */
public class PreorderTree extends SortedTree {

    public PreorderTree(StringTree parent, StringTree leftchild, StringTree rightchild, String key) {
        super(parent, leftchild, rightchild, key);
    }

    @Override
    public String traverse() {
        String ret = "";
        ret += label;
        if (leftchild != null) {
            ret += " " + ((SortedTree) leftchild).traverse();
        }
        if (rightchild != null) {
            ret += " " + ((SortedTree) rightchild).traverse();
        }
        return ret;
    }
    
    public SortedTree getNewInstance() {
        return new PreorderTree(null, null, null, "");
    }
}
